<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <p>当前数位:{{sum}}</p>
        <button @click="jia">+</button>
        <button @click="jian">-</button>
    </div>
    <script src="../../node_modules/vue/dist/vue.js"></script>
    <script>
        var app = new Vue({
            el: '#app',
            data: {
                sum: 0
            },
            methods: {
                jia: function() {
                    if (this.sum >= 10) {
                        alert('最大了');
                    } else {
                        this.sum++;
                    }

                },
                jian: function() {
                    if (this.sum <= 0) {
                        alert("最小了");
                    } else {
                        this.sum--;
                    }
                }
            }
        })
    </script>
</body>

</html>